home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Database How-To
/
Visual Basic 4 Database - How-to (The Waite Group)(1995).iso
/
select4.fr_
/
select4.fr
Wrap
Text File
|
1995-07-04
|
6KB
|
202 lines
VERSION 4.00
Begin VB.Form Form1
BackColor = &H00C0C0C0&
Caption = "Wildcard and Range SELECTer"
ClientHeight = 3735
ClientLeft = 1740
ClientTop = 2490
ClientWidth = 7575
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 700
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 4140
Left = 1680
LinkTopic = "Form1"
ScaleHeight = 3735
ScaleWidth = 7575
Top = 2145
Width = 7695
Begin VB.CommandButton cmdLookup
Caption = "&Look Up"
Default = -1 'True
Height = 555
Left = 2100
TabIndex = 8
Top = 2880
Width = 1335
End
Begin VB.TextBox txtEndYear
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 400
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 285
Left = 3840
TabIndex = 4
Top = 2280
Width = 855
End
Begin VB.TextBox txtStartYear
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 400
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 285
Left = 2400
TabIndex = 3
Top = 2280
Width = 855
End
Begin VB.TextBox txtPartialTitle
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 400
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 315
Left = 2400
TabIndex = 2
Top = 1800
Width = 4635
End
Begin VB.CommandButton cmdClose
Caption = "&Close"
Height = 555
Left = 4200
TabIndex = 1
Top = 2880
Width = 1335
End
Begin VB.ListBox lstTitles
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 400
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 1230
Left = 480
TabIndex = 0
Top = 240
Width = 6555
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "and"
Height = 195
Left = 3360
TabIndex = 7
Top = 2340
Width = 330
End
Begin VB.Label Label2
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "Published between:"
Height = 195
Left = 540
TabIndex = 6
Top = 2340
Width = 1680
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "Title includes text:"
Height = 195
Left = 540
TabIndex = 5
Top = 1860
Width = 1590
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
' Change the following to point to your copy of BIBLIO.MDB.
Private Sub cmdLookup_Click()
Dim db As DATABASE
Dim dbName As String
Dim rs As Recordset
Dim sql As String
Dim titleText As String, startYear As String, endYear As String
' Set up the error handler.
On Error GoTo LookupError
lstTitles.Clear
titleText = IIf(txtPartialTitle <> "", txtPartialTitle, "*")
startYear = IIf(IsNumeric(txtStartYear), txtStartYear, "1")
endYear = IIf(IsNumeric(txtEndYear), txtEndYear, "9999")
' Get the database name and open the database.
dbName = BiblioPath() ' BiblioPath is a function in READINI.BAS
Set db = DBEngine.Workspaces(0).OpenDatabase(dbName)
' Open a snapshot-type recordset on the [Titles] Table, selecting only
' those titles published in 1993 or 1994. Sort the records by the ISBN
' number.
sql = "SELECT [Title] FROM [Titles]"
sql = sql & " WHERE [Title] LIKE '*" & titleText & "*'"
sql = sql & " AND [Year Published] BETWEEN " & startYear & " AND " & endYear
sql = sql & " ORDER BY [Title]"
Set rs = db.OpenRecordset(sql, dbOpenSnapshot)
' If there is at least one record in the recordset, move through the
' recordset a record at a time until the end of the file (EOF) is
' reached. Display each record in the unbound list box lstTitles.
If rs.RecordCount > 0 Then
rs.MoveFirst
Do While Not rs.EOF
lstTitles.AddItem rs![Title]
rs.MoveNext
Loop
End If
Exit Sub
LookupError:
' Just display Visual Basic's default error message.
MsgBox Error(Err)
Exit Sub
End Sub
Private Sub cmdClose_Click()
End
End Sub